import threading
import time

def working():
    for i in range(10):
        print(i)
        time.sleep(0.2)

if __name__ == '__main__':
    # 方式1：设置守护住主线程
    # sub_thread = threading.Thread(target=working,daemon=True)

    # 方式2：通过方法设置守护主线程
    sub_thread = threading.Thread(target=working)
    sub_thread.setDaemon(True)

    sub_thread.start()

    time.sleep(1)
    print('主线程结束')